class Project < ActiveRecord::Base
  
  validates_presence_of :name, :on => :create
  validates_presence_of :name, :on => :update
  
  def Project.from_xml xml 
    xml_doc = REXML::Document.new(xml)
    projects = []
    xml_doc.elements.each('Projects/Project') do |projectElement|
      project = Project.new();
      project.name = projectElement.attributes['name']
      project.activity = projectElement.attributes['activity']
      project.last_build_status = projectElement.attributes['lastBuildStatus']
      project.last_build_label = projectElement.attributes['lastBuildLabel']
      project.last_build_time = projectElement.attributes['lastBuildTime']
      project.next_build_time = projectElement.attributes['nextBuildTime']
      projects << project
    end
    return projects
  end
  
end
